#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

script=$PWD/$0
path=$(dirname $script)
work_path=$(dirname $path)
docker_path=$work_path/docker
mysql_path=$docker_path/mysql

# echo "chmod -R 777 $mysql_path/data";
# chmod -R 777 $mysql_path/data
# echo "chmod -R 777 $mysql_path/log";
# chmod -R 777 $mysql_path/log

server_file=$docker_path/bt/conf/server_ip
server_conf=$docker_path/bt/conf/127.0.0.1.conf
cp $server_conf.bk $server_conf
echo -n 'server_name=' > $server_file
wget http://ipecho.net/plain -O - -q  >> $server_file
source $docker_path/bt/conf/server_ip
sed -i "s/255.255.255.255/$server_name/g" $server_conf
rm -rf $server_file